package com.su.lightthings.viewmodel

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.su.lightthings.bean.BaseDataBean
import com.su.lightthings.bean.RealTimeInfoBean
import com.su.lightthings.bean.SportDataBean
import com.su.lightthings.bean.SportPageItemBean
import com.su.lightthings.bean.TargetInfoBean

class DataViewModel : ViewModel() {
    companion object {
        private const val TAG = "DataViewModel"

        val INSTANCE: DataViewModel by lazy {
            DataViewModel()
        }
    }

    val batteryMLD = MutableLiveData<Int>()
    val heartMLD = MutableLiveData<Int>()
    val oxygenMLD = MutableLiveData<MutableList<BaseDataBean>>()
    val sleepMLD = MutableLiveData<MutableList<Int>>()
    val realTimeInfoBean = MutableLiveData<RealTimeInfoBean>()
    val targetInfoBean = MutableLiveData<TargetInfoBean>()
    val allFunctionList = MutableLiveData<MutableList<Int>>(mutableListOf())
    val sportFunctionList = MutableLiveData<MutableList<SportPageItemBean>>(mutableListOf())
    val sportViewList = MutableLiveData<MutableList<SportPageItemBean>>(mutableListOf())

    var notifySwitch = false
//    val appNotify = Cons.FunctionItemList.notificationList.toMutableList()

    val sportDataMLD = MutableLiveData<MutableList<SportDataBean>>(mutableListOf())
    // 运动距离总和
    val sportDistanceMLD = MutableLiveData<Int>(0)
    // 实时距离
    val realTimeDistanceMLD = MutableLiveData<Int>(0)

    /**
     *
     */
    fun updateNotifyInfo(isSwitch: Boolean, appList: MutableList<Int>) {
        //更新消息开关数据
        notifySwitch = isSwitch
//        for ((index, item) in appNotify.withIndex()) {
//            item.state = appList[index] == 1
//        }
        Log.d(TAG, "更新消息开关数据 :  $isSwitch  >>  $appList   ")
    }


    /**
     * 手表连接断开，清楚缓存数据
     */
    fun clearData() {
        allFunctionList.postValue(mutableListOf())
        sportFunctionList.postValue(mutableListOf())
        sportViewList.postValue(mutableListOf())
    }

}